<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Register a function for execution on each tick</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.register-tick-function" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">register_tick_function</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.3, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">register_tick_function</span> &mdash; <span class="dc-title">Register a function for execution on each tick</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.register-tick-function-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>register_tick_function</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$function</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$arg</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$...</code></span>
  ]] ) : <span class="type">bool</span></div>

  <p class="simpara">
   Registers the given <code class="parameter">function</code> to be executed when a
   <a href="control-structures.declare.html#control-structures.declare.ticks" class="link">tick</a> is called.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.register-tick-function-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">function</code></dt>

     <dd>

      <p class="para">
       The function name as a string, or an array consisting of an object and
       a method.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">arg</code></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">...</code></dt>

     <dd>

      <p class="para">
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.register-tick-function-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.register-tick-function-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-6209">
    <p><strong>Example #1 <span class="function"><strong>register_tick_function()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">declare(</span><span style="color: #0000BB">ticks</span><span style="color: #007700">=</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;using&nbsp;a&nbsp;function&nbsp;as&nbsp;the&nbsp;callback<br /></span><span style="color: #0000BB">register_tick_function</span><span style="color: #007700">(</span><span style="color: #DD0000">'my_function'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;using&nbsp;an&nbsp;object-&gt;method<br /></span><span style="color: #0000BB">$object&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">my_class</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">register_tick_function</span><span style="color: #007700">(array(&amp;</span><span style="color: #0000BB">$object</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'my_method'</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.register-tick-function-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.0</td>
       <td>
        Ticks are now supported on threaded web server modules.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.register-tick-function-notes">
  <h3 class="title">注释</h3>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="para">
    <span class="function"><strong>register_tick_function()</strong></span> should not be used with
    threaded web server modules with PHP 5.2 or lower.
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.register-tick-function-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="control_structures.declare.html" class="link">declare</a></li>
    <li class="member"><span class="function"><a href="unregister_tick_function.html" class="function" rel="rdfs-seeAlso">unregister_tick_function()</a> - De-register a function for execution on each tick</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>